package Initial

import (
	"gamers/core"
	"k8s.io/client-go/kubernetes"
	"k8s.io/client-go/tools/clientcmd"
)

func InitializeKubernetes() (err error) {
	// 设置kubeconfig文件路径
	kubeconfig := ".kube/config"
	// 从kubeconfig文件中获取配置信息
	config, err := clientcmd.BuildConfigFromFlags("", kubeconfig)
	if err != nil {
		return err
	}

	// 创建kubernetes的clientset
	clientset, err := kubernetes.NewForConfig(config)
	if err != nil {
		return err
	}
	// 赋值全局
	core.KubeClient = clientset
	return err
}
